import defaultSettings from '@/settings'
import storeUtil from '@/utils/store'

const TokenKey = `${defaultSettings.projectName}-Token`
const UserKey = `${defaultSettings.projectName}-User`

/**
 * @Author tangyuhui
 * @Description 清除登录信息
 * @Date 2021-03-21 11:21:20 Sunday
 */
export function removeLoginMsg() {
  // 清除token
  removeToken()
  // 清除user
  removeUser()
}

export function getToken() {
  return storeUtil.getLocalStore(TokenKey)
}

export function setToken(token) {
  return storeUtil.setLocalStore(TokenKey, token)
}

export function removeToken() {
  return storeUtil.removeLocalStore(TokenKey)
}

export function getUser() {
  const user = storeUtil.getLocalStore(UserKey)
  if (user) {
    return JSON.parse(user)
  }
  return null
}

export function setUser(user) {
  return storeUtil.setLocalStore(UserKey, user)
}

export function removeUser() {
  return storeUtil.removeLocalStore(UserKey)
}

